﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using WeChatDemo.Models.DTO.Photo;
using WeChatDemo.Models.Photo;

namespace WeChatDemo.DataProvider.Photo
{
    public class DAOPhotoUserDetails : DAOBase
    {
        private static string tableName = "PhotoUser";

        public static PhotoUser GetModel(Guid userId)
        {
            string queryExpression = $"AND ID = '{userId}'";
            IEnumerable<PhotoUser> _list = ReaderToList<PhotoUser>(queryExpression, tableName);

            return _list.ElementAtOrDefault<PhotoUser>(0);
        }

        public static PhotoUser GetModel(string userName, string mobile)
        {
            string queryExpression = $"AND UserName = '{userName}' AND Mobile = '{mobile}'";
            IEnumerable<PhotoUser> _list = ReaderToList<PhotoUser>(queryExpression, tableName);

            return _list.ElementAtOrDefault<PhotoUser>(0);
        }

        public static PhotoUser GetModel(string mobile)
        {
            string queryExpression = $"AND Mobile = '{mobile}'";
            IEnumerable<PhotoUser> _list = ReaderToList<PhotoUser>(queryExpression, tableName);

            return _list.ElementAtOrDefault<PhotoUser>(0);
        }

        public static IEnumerable<DTOPhotoUser> GetList(string queryExpression)
        {
            IEnumerable<DTOPhotoUser> _list = ReaderToList<DTOPhotoUser>(queryExpression, tableName);

            return _list;
        }
    }
}